{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## math — Mathematical functions¶"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Number-theoretic and representation functions¶"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "#### math.ceil(x)\n",
    "\n",
    "    Return the ceiling of x, the smallest integer greater than or equal to x. If x is not a float, delegates to x.__ceil__(), which should return an Integral value.\n",
    "\n",
    "\n",
    "\n",
    "#### math.copysign(x, y)\n",
    "\n",
    "    Return a float with the magnitude (absolute value) of x but the sign of y. On platforms that support signed zeros, copysign(1.0, -0.0) returns -1.0.\n",
    "\n",
    "#### math.fabs(x)\n",
    "\n",
    "    Return the absolute value of x.\n",
    "\n",
    "#### math.factorial(x)\n",
    "\n",
    "    Return x factorial. Raises ValueError if x is not integral or is negative.\n",
    "\n",
    "#### math.floor(x)\n",
    "\n",
    "    Return the floor of x, the largest integer less than or equal to x. If x is not a float, delegates to x.__floor__(), which should return an Integral value.\n",
    "\n",
    "#### math.gcd(a, b)\n",
    "\n",
    "    Return the greatest common divisor of the integers a and b. If either a or b is nonzero, then the value of gcd(a, b) is the largest positive integer that divides both a and b. gcd(0, 0) returns 0.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "import math"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1000"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.ceil(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-1000.0"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.copysign(x,-2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1000.0"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.fabs(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3628800"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.factorial(x/100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "434"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.floor(1000/2.3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.gcd(4,5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Power and logarithmic functions¶"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### math.exp(x)\n",
    "\n",
    "    Return e raised to the power x, where e = 2.718281… is the base of natural logarithms. This is usually more accurate than math.e ** x or pow(math.e, x).\n",
    "\n",
    "### math.expm1(x)\n",
    "\n",
    "    Return e raised to the power x, minus 1. Here e is the base of natural logarithms. For small floats x, the subtraction in exp(x) - 1 can result in a significant loss of precision; the expm1() function provides a way to compute this quantity to full precision:\n",
    "\n",
    "\n",
    "### math.log(x[, base])\n",
    "\n",
    "    With one argument, return the natural logarithm of x (to base e).\n",
    "\n",
    "    With two arguments, return the logarithm of x to the given base, calculated as log(x)/log(base).\n",
    "\n",
    "### math.log1p(x)\n",
    "\n",
    "    Return the natural logarithm of 1+x (base e). The result is calculated in a way which is accurate for x near zero.\n",
    "\n",
    "### math.log2(x)\n",
    "\n",
    "    Return the base-2 logarithm of x. This is usually more accurate than log(x, 2).\n",
    "    \n",
    "\n",
    "### math.log10(x)\n",
    "\n",
    "    Return the base-10 logarithm of x. This is usually more accurate than log(x, 10).\n",
    "\n",
    "### math.pow(x, y)\n",
    "\n",
    "    Return x raised to the power y. Exceptional cases follow Annex ‘F’ of the C99 standard as far as possible. In particular, pow(1.0, x) and pow(x, 0.0) always return 1.0, even when x is a zero or a NaN. If both x and y are finite, x is negative, and y is not an integer then pow(x, y) is undefined, and raises ValueError.\n",
    "\n",
    "    Unlike the built-in ** operator, math.pow() converts both its arguments to type float. Use ** or the built-in pow() function for computing exact integer powers.\n",
    "\n",
    "\n",
    "\n",
    "### math.sqrt(x)\n",
    "\n",
    "    Return the square root of x.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "54.598150033144236"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.exp(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.830951894845301"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.sqrt(34)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9030899869919435"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.log10(8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "81.0"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.pow(3,4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.718281828459045"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.expm1(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0986122886681096"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.log1p(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.log2(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Trigonometric functions\n",
    "\n",
    "math.acos(x)\n",
    "\n",
    "    Return the arc cosine of x, in radians.\n",
    "\n",
    "math.asin(x)\n",
    "\n",
    "    Return the arc sine of x, in radians.\n",
    "\n",
    "math.atan(x)\n",
    "\n",
    "    Return the arc tangent of x, in radians.\n",
    "\n",
    "math.atan2(y, x)\n",
    "\n",
    "    Return atan(y / x), in radians. The result is between -pi and pi. The vector in the plane from the origin to point (x, y) makes this angle with the positive X axis. The point of atan2() is that the signs of both inputs are known to it, so it can compute the correct quadrant for the angle. For example, atan(1) and atan2(1, 1) are both pi/4, but atan2(-1, -1) is -3*pi/4.\n",
    "\n",
    "math.cos(x)\n",
    "\n",
    "    Return the cosine of x radians.\n",
    "\n",
    "math.hypot(x, y)\n",
    "\n",
    "    Return the Euclidean norm, sqrt(x*x + y*y). This is the length of the vector from the origin to point (x, y).\n",
    "\n",
    "math.sin(x)\n",
    "\n",
    "    Return the sine of x radians.\n",
    "\n",
    "math.tan(x)\n",
    "\n",
    "    Return the tangent of x radians.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9272952180016123"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.acos(0.6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.9899924966004454"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.cos(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.1411200080598672"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.sin(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-2.185039863261519"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.tan(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5235987755982989"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.asin(0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.1071487177940904"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.atan(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.1071487177940904"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "math.atan2(4,2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Angular conversion\n",
    "\n",
    "math.degrees(x)\n",
    "\n",
    "    Convert angle x from radians to degrees.\n",
    "\n",
    "math.radians(x)\n",
    "\n",
    "    Convert angle x from degrees to radians.\n",
    "\n",
    "### Hyperbolic functions\n",
    "\n",
    "Hyperbolic functions are analogs of trigonometric functions that are based on hyperbolas instead of circles.\n",
    "\n",
    "math.acosh(x)\n",
    "\n",
    "    Return the inverse hyperbolic cosine of x.\n",
    "\n",
    "math.asinh(x)\n",
    "\n",
    "    Return the inverse hyperbolic sine of x.\n",
    "\n",
    "math.atanh(x)\n",
    "\n",
    "    Return the inverse hyperbolic tangent of x.\n",
    "\n",
    "math.cosh(x)\n",
    "\n",
    "    Return the hyperbolic cosine of x.\n",
    "\n",
    "math.sinh(x)\n",
    "\n",
    "    Return the hyperbolic sine of x.\n",
    "\n",
    "math.tanh(x)\n",
    "\n",
    "    Return the hyperbolic tangent of x.\n",
    "\n",
    "### Special functions\n",
    "\n",
    "math.erf(x)\n",
    "\n",
    "    Return the error function at x.\n",
    "\n",
    "    The erf() function can be used to compute traditional statistical functions such as the cumulative standard normal distribution:\n",
    "\n",
    "    def phi(x):\n",
    "        'Cumulative distribution function for the standard normal distribution'\n",
    "        return (1.0 + erf(x / sqrt(2.0))) / 2.0\n",
    "\n",
    "    New in version 3.2.\n",
    "\n",
    "math.erfc(x)\n",
    "\n",
    "    Return the complementary error function at x. The complementary error function is defined as 1.0 - erf(x). It is used for large values of x where a subtraction from one would cause a loss of significance.\n",
    "\n",
    "    New in version 3.2.\n",
    "\n",
    "math.gamma(x)\n",
    "\n",
    "    Return the Gamma function at x.\n",
    "\n",
    "    New in version 3.2.\n",
    "\n",
    "math.lgamma(x)\n",
    "\n",
    "    Return the natural logarithm of the absolute value of the Gamma function at x.\n",
    "\n",
    "    New in version 3.2.\n",
    "\n",
    "### Constants\n",
    "\n",
    "math.pi\n",
    "\n",
    "    The mathematical constant π = 3.141592…, to available precision.\n",
    "\n",
    "math.e\n",
    "\n",
    "    The mathematical constant e = 2.718281…, to available precision.\n",
    "\n",
    "math.tau\n",
    "\n",
    "    The mathematical constant τ = 6.283185…, to available precision. Tau is a circle constant equal to 2π, the ratio of a circle’s circumference to its radius. To learn more about Tau, check out Vi Hart’s video Pi is (still) Wrong, and start celebrating Tau day by eating twice as much pie!\n",
    "\n",
    "\n",
    "math.inf\n",
    "\n",
    "    A floating-point positive infinity. (For negative infinity, use -math.inf.) Equivalent to the output of float('inf').\n",
    "\n",
    "   \n",
    "\n",
    "math.nan\n",
    "\n",
    "    A floating-point “not a number” (NaN) value. Equivalent to the output of float('nan').\n",
    "\n",
    "  \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
